<?php

	error_reporting(E_ALL);
	
    class Header {
    
        function CompileHeader($title='Love the PHP!',$description='John\'s PHP Digest, Free downloads and tutorials, examples and articles on random webmaster information, from apache to php.'){
    
			return Parser::Parse(array('template'=>'/template/header.tpl','bbcode'=>FALSE),
							array('{TITLE}','{MENU}','{DESCRIPTION}'),
							array('John\'s PHP Digest - '.$title,Header::CompileMenu(),Header::CompileDescription($description)));

        }
        
        function CompileMenu(){
        
            $value = str_replace(array('/','.php'),'',$_SERVER['PHP_SELF']);
            $link1 = array('<li>index</li>','<li>products</li>','<li>tutorials</li>','<li>portfolio</li>','<li>contact</li>');
            $replace = array('<li>','</li>');
			
			$str = NULL;
			
            foreach ($link1 as $link){
			
                $link = str_replace($replace,'',$link);
		
                if($link==$value){ 
                    $str .= '<li id="selected"><a href="'.$link.'" title="'.ucfirst($link).'">'.ucfirst($link).'</a></li>'; 
                } else {
                    $str .= '<li><a href="'.$link.'" title="'.ucfirst($link).'">'.ucfirst($link).'</a></li>';	
                }
    
            }
			
			return $str;

        }
		
		function CompileDescription($str){
			
			// Remove any formatting made by the SQL
			$find = array('<p>','</p>','<strong>','</strong>','<ul>','<li>','</ul>','</li>','<h2>','</h2>');
			$replace = array('');
			$str = str_replace($find,$replace,$str);
			
			// Strip URL Tag
			$find = array("/<a href=(.*?)>(.*?)<\\/a>/i",'((\r\n)+)');
			$replace = array('$2','');
			$str = preg_replace($find, $replace, $str);
			
			return htmlentities($str);
		
		}
    
    }
    
?>